package com.sch.www.common.util;

public class IfElseUtil {


    public static Object ifElse(boolean ifCondition, Object ifValue) {
        return ifElse(ifCondition, ifValue, null);

    }

    public static Object ifElse(boolean ifCondition1, Object ifValue1, Object defaultValue) {
        if (ifCondition1) {
            return ifValue1;
        } else {
            return defaultValue;
        }
    }

    public static Object ifElse(boolean ifCondition1, Object ifValue1, boolean ifCondition2, Object ifValue2) {
        return ifElse(ifCondition1, ifValue1, ifCondition2, ifValue2, null);
    }

    public static Object ifElse(boolean ifCondition1, Object ifValue1, boolean ifCondition2, Object ifValue2, Object defaultValue) {

        Object value = ifElse(ifCondition1, ifValue1);
        if (value != null) {
            return value;
        } else {
            return ifElse(ifCondition2, ifValue2, defaultValue);
        }

    }


    public static Object ifElse(boolean ifCondition1, Object ifValue1, boolean ifCondition2, Object ifValue2, boolean ifCondition3, Object ifValue3) {
        return ifElse(ifCondition1, ifValue1, ifCondition2, ifValue2, null);
    }

    public static Object ifElse(boolean ifCondition1, Object ifValue1, boolean ifCondition2, Object ifValue2, boolean ifCondition3, Object ifValue3, Object defaultValue) {
        Object value = ifElse(ifCondition1, ifValue1);
        if (value != null) {
            return value;
        } else {
            return ifElse(ifCondition2, ifValue2, ifCondition3, ifValue3, defaultValue);
        }
    }


    public static Object ifElse(boolean ifCondition1, Object ifValue1, boolean ifCondition2, Object ifValue2, boolean ifCondition3, Object ifValue3, boolean ifCondition4, Object ifValue4) {
        return ifElse(ifCondition1, ifValue1, ifCondition2, ifValue2, null);
    }

    public static Object ifElse(boolean ifCondition1, Object ifValue1, boolean ifCondition2, Object ifValue2, boolean ifCondition3, Object ifValue3, boolean ifCondition4, Object ifValue4, Object defaultValue) {
        Object value = ifElse(ifCondition1, ifValue1);
        if (value != null) {
            return value;
        } else {
            return ifElse(ifCondition2, ifValue2, ifCondition3, ifValue3, ifCondition4, ifValue4, defaultValue);
        }
    }

    public static Object ifElse(boolean ifCondition1, Object ifValue1, boolean ifCondition2, Object ifValue2, boolean ifCondition3, Object ifValue3, boolean ifCondition4, Object ifValue4, boolean ifCondition5, Object ifValue5) {
        return ifElse(ifCondition1, ifValue1, ifCondition2, ifValue2, null);
    }

    public static Object ifElse(boolean ifCondition1, Object ifValue1, boolean ifCondition2, Object ifValue2, boolean ifCondition3, Object ifValue3, boolean ifCondition4, Object ifValue4, boolean ifCondition5, Object ifValue5, Object defaultValue) {
        Object value = ifElse(ifCondition1, ifValue1);
        if (value != null) {
            return value;
        } else {
            return ifElse(ifCondition2, ifValue2, ifCondition3, ifValue3, ifCondition4, ifValue4, ifCondition5, ifValue5, defaultValue);
        }
    }

    public static void main(String args[]) {
        for (int i = 0; i <= 5; i++) {
            Object v = ifElse(
                    i == 0, 0,
                    i == 1, 1,
                    i == 2, 2,
                    i == 3, 3,
                    i == 4, 4,
                    -1
            );
            System.out.println(v);
        }
    }

}
